package com.haoshuang.zhouzhoubang.ui.page.mine.notice.publish

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class PublishNoticeViewModel : BaseViewModel() {

    /**
     * 发布通知
     */
    val publishNoticeData = StatefulMutableLiveData<ResponseBean<Any>>()
    fun publishNotice(ids: String, content: String) = netRequest {
        start { publishNoticeData.value = StateData.Loading }
        request { ApiRepo.publishNotice(ids, content)  }
        success { publishNoticeData.value = StateData.Success(it) }
        error { code, msg ->
            publishNoticeData.value = StateData.Error(code, msg)
        }
    }

}